package cloud.maque.module.system.controller;

import cloud.maque.common.core.request.PageRequest;
import cloud.maque.common.core.response.R;
import cloud.maque.module.system.entity.SysPost;
import cloud.maque.module.system.service.PostService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 岗位
 */
@Tag(name = "岗位接口")
@RestController
@RequestMapping(value = "/post")
public class PostController {


    @Autowired
    PostService postService;

    @Operation(summary = "岗位查询列表")
    @PostMapping("/list")
    public R<IPage<SysPost>> List(@RequestBody PageRequest<SysPost> pageReq) {
        return R.ok("OK", postService.GetList(pageReq));
    }

    @Operation(summary = "岗位保存")
    @PostMapping("/save")
    public R<SysPost> Save(@RequestBody SysPost data) {

        return R.ok("OK", postService.SavePost(data));
    }

    @Operation(summary = "岗位状态修改")
    @PostMapping("/edit-status")
    public R<SysPost> EditStatus(@RequestBody SysPost data) {
        return R.ok("OK", postService.EditStatus(data));
    }


    @Operation(summary = "岗位删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> Delete(@PathVariable("id") String id) {
        return R.ok("OK", postService.DeletePost(id));
    }
}
